import {
  _decorator,
  Component,
  Node,
  NodeEventType,
  SpriteFrame,
  director
} from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Home')
export class Home extends Component {
  @property(Node)
  btn_Root: Node | null = null;
  @property(Node)
  active_btn: Node | null = null;
  @property(Node)
  none_btn: Node | null | null;

  activeBtnSpriteFrame: SpriteFrame | null = null;
  btnSpreiteFrame: SpriteFrame | null = null;

  protected onLoad(): void {
    if (this.btn_Root) {
      this.btn_Root.on(NodeEventType.TOUCH_START, this.onTouchStart, this);
      this.btn_Root.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
    } else {
      console.warn('btn 节点未绑定！');
    }
  }

  onTouchStart() {
    this.active_btn.active = false;
    this.none_btn.active = true;
  }

  onTouchEnd() {
    this.active_btn.active = true;
    this.none_btn.active = false;
  }

  onStartPlay() {
    director.loadScene('game')
  }
}
